package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * 数据字典-经销商账号状态
 *
 * @author lee
 * @version v1.0
 * @date 2020/12/23 10:19
 * @since v1.0
 */
@Getter
public enum DistributorAccountStatusEnum {



    ENABLE("1", "enum.distributorAccountStatus.name.enable"),


    DISABLE("0", "enum.distributorAccountStatus.name.disable"),

    ;

    private String code;
    private String name;

    DistributorAccountStatusEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public static String getByCode(String code) {
        for (DistributorAccountStatusEnum value : DistributorAccountStatusEnum.values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value.getName();
            }
        }
        return null;
    }
}
